package com.hxk.di.bean;

import org.springframework.beans.factory.annotation.Value;

/**
 * 使用@Value注解实现赋值的方式对象
 */
public class BeanValue {

    @Value("李四")//直接给name赋值为“李四”
    private String name;

    @Value("#{18+2}")//动态运算算赋值
    private Integer age;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return "BeanValue{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}
